package connect4client.commands;

import messages.UserLoggedOutMessage;
import connect4client.core.PlayerManager;

/**
 * The UserLoggedOut command.
 * 
 * This command will handle UserLoggedIn messages.
 */
public class UserLoggedOutCommand extends Command{

	public UserLoggedOutCommand(UserLoggedOutMessage userLoggedInCommand) {
		super(userLoggedInCommand);	
	}

	@Override
	public void execute() {		
		UserLoggedOutMessage message = (UserLoggedOutMessage) this.message;		
		PlayerManager playerManager = controller.getPlayerManager();
		
		synchronized (playerManager) {
			playerManager.removePlayer(message.getPlayerLogin());
		}
		
		guiMediator.userLoggedOut(message.getPlayerLogin());
	}	
}
